import 'package:animations/animations.dart';
import 'package:eyepetizer_example/config/string.dart';
import 'package:eyepetizer_example/page/search_page.dart';
import 'package:eyepetizer_example/widget/app_bar.dart';
import 'package:flutter/material.dart';

import 'home_page_body.dart';

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  State<StatefulWidget> createState() => _HomePageState();
}

class _HomePageState extends State<StatefulWidget>
    with AutomaticKeepAliveClientMixin {
  @override
  Widget build(BuildContext context) {
    super.build(context);
    return Scaffold(
        appBar: appBar(AppString.home, showBack: false,
          actions: <Widget>[
            // 搜索图标
            _searchIcon(),
          ],
        ),
        body: const HomePageBodyPage());
  }

  /// 搜索图标
  Widget _searchIcon() {
    return Padding(
      padding: const EdgeInsets.only(right: 15),
      child: OpenContainer(
        closedElevation: 0.0,
        closedBuilder: (context, action) {
          return const Icon(
            Icons.search,
            color: Colors.black87,
          );
        },
        openBuilder: (context, action) {
          return SearchPage();
        },
      ),
    );
  }

  @override
  bool get wantKeepAlive => true;
}
